﻿using System;
using System.Web;
using System.Web.Routing;
using Ext.Direct.Mvc.Configuration;

namespace Ext.Direct.Mvc
{
    public class DirectHttpModule : IHttpModule
    {
        public void Init(HttpApplication context) {
            // Mapping Direct API configurator url
            RouteTable.Routes.Insert(0, new Route(
                DirectConfig.ApiUrl,
                new RouteValueDictionary(new { controller = "", action = "" }),
                new DirectMvcRouteHandler()
            ));

            // Mapping Direct router url
            RouteTable.Routes.Insert(1, new Route(
                DirectConfig.RouterUrl,
                new RouteValueDictionary(new { controller = "", action = "" }),
                new DirectMvcRouteHandler()
            ));
        }

        public void Dispose() { }
    }
}
